package com.zy.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.zy.bean.qo.SystemCmpQo;
import com.zy.bean.vo.SystemCmpVo;
import com.zy.service.RuleComponentService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.fatewa.engine.advice.annotations.OriginalResponse;
import org.fatewa.engine.advice.protocol.RayquazaResponse;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 规则组件有关的接口
 *
 * @author hanhuafeng
 * @version V1.0
 * @description
 * @date 2023/7/18
 */
@RestController
@RequestMapping("/v1/component")
@RequiredArgsConstructor
@Slf4j
public class ComponentController {
    private final RuleComponentService ruleComponentService;

    /**
     * 查询所有的组件
     *
     * @return 某个组件类型下对应的所有的组件
     */
    @GetMapping("")
    @OriginalResponse
    public RayquazaResponse list() {
        return new RayquazaResponse(ruleComponentService.listAll());
    }

    /**
     * 分页查询系统组件
     *
     * @return 返回系统组件
     */
    @GetMapping("/system")
    public IPage<SystemCmpVo> listSystemComponent(SystemCmpQo qo) {
        return ruleComponentService.listSystemComponent(qo);
    }
}
